
package com.moogene.android.engine.animlite;

public class Anime {
    public static final int STATE_STOP = 0;

    public static final int STATE_RUNNING = 1;

    public static final int STATE_PAUSE = 2;

    protected DrawableWrapper drawableWrapper;

    protected int mState;

    private long fpsCounter;

    private int mFps = 1;

    Anime(DrawableWrapper drawableWrapper) {
        this.drawableWrapper = drawableWrapper;
    }

    void start() {
        fpsCounter = -1;
        mState = STATE_RUNNING;
    }

    public void pause() {
        mState = STATE_PAUSE;
    }

    public void resume() {
        fpsCounter = -1;
        mState = STATE_RUNNING;
    }

    public void stop() {
        mState = STATE_STOP;
    }

    public boolean isRunning() {
        return mState == STATE_RUNNING;
    }

    public boolean isStopped() {
        return mState == STATE_STOP;
    }
    
    public boolean isPaused() {
        return mState == STATE_PAUSE;
    }

    public void setFps(int fps) {
        mFps = fps;
    }

    boolean nextFrame() {
        if (mState != STATE_RUNNING) {
            return false;
        }
        fpsCounter++;
        if (fpsCounter
                % mFps == 0) {
            return true;
        }
        return false;
    }

}
